home *** CD-ROM | disk | FTP | other *** search
- Path: lassen.cnw.com!matt!matt
- From: matt@matt.fidalgo.net (Matt Gischer)
- Newsgroups: comp.lang.c
- Subject: Paging program
- Date: Tue, 12 Mar 1996 08:02:17 GMT
- Organization: Uncle Fran's Musical Forest
- Message-ID: <Do5ABu.1v0@matt.fidalgo.net>
- NNTP-Posting-Host: fidnet-30.fidalgo.net
- X-Newsreader: TIN [UNIX 1.3 BETA-950824-color PL0]
-
- I'm trying to get this program here to work. It's supposed to take a
- file (from stdin or the command line) and pause every 24 lines.
- (although i'd like some insight on how to find out how many rows the
- users terminal has). Anyway.. this thing prints out the last line of the
- file however many lines it is short of a full page on the last page.
- So.. i was wondering if anyone could help me with that. Thanks.
-
- #include <stdio.h>
-
- main(int argc, char *argv[])
- {
- FILE *in;
- char t[80],enter;
- int x=0,z=0,s=0,y=0;
- if((in=fopen(argv[1], "r"))==NULL) {
- in=stdin;
- }
- while(!feof(in)) {
- fgets(t, 79,in);
- x++;
- }
- x--;
- rewind(in);
- y=x/24;
- if((y*24)<x) {
- y++;
- }
- for(s=0;s<y;s++) {
- for(z=0;z<24;z++) {
- fgets(t,79,in);
- if(t!=NULL) {
- print(t);
- }
- }
- if(x>=24) {
- printf("Hit enter for more");
- enter=getchar();
- }
- }
- fclose(in);
- return 0;
- }
-
-